/*
 * Project Beknyou
 * Copyright (c) 2010-2011 Saint Paul College, All Rights Reserved
 * Redistributions in source code form must reproduce the above
 * Copyright and this condition.
 * The contents of this file are subject to the GNU General Public
 * License, Version 2 (the "License"); you may not use this file
 * except in compliance with the License. A copy of the License is
 * available at http://www.opensource.org/licenses/gpl-license.php.
 */
package com.benkyou.client.network;

import com.benkyou.client.GameClient;
import com.benkyou.common.messages.LoginMessage;
import com.benkyou.common.messages.PlayerMessage;
import com.jme3.network.Client;
import com.jme3.network.Message;
import com.jme3.network.MessageListener;

/**
 *
 * @author Austin Allman
 */
public class LoginListener implements MessageListener<Client>{
    private GameClient gameClient;

    /**
     * 
     * @param gameClient
     */
    public LoginListener(GameClient gameClient) {
        this.gameClient = gameClient;
    }

    /**
     * 
     * @param source
     * @param m
     */
    public void messageReceived(Client source, Message m) {
        if(m instanceof LoginMessage){
            LoginMessage loginMessage = (LoginMessage) m;
            gameClient.addPlayer(loginMessage.getLoginName(), loginMessage.getID(), loginMessage.getUUID());
            gameClient.setNewPlayer(true);
        }
    
    }
    
}
